<?php

namespace App\Admin\Controllers;

use App\Models\StocksOrder;
use App\Models\User;
use App\Models\UserLog;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class StockOrderController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '明细查询';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new StocksOrder());

        $grid->column('id', __('Id'))->sortable();
        //  $grid->column('user.username', __('用户'))->sortable();
        $grid->column('member_id', __('用户id'))->sortable();
        $grid->column('order_no', __('订单编号'))->sortable();
        $grid->column('symbol_code', __('产品code'))->sortable();
        $grid->column('volume', __('手数'))->sortable();
        $grid->column('open_time', __('开仓时间'))->sortable();

        $grid->disableCreateButton();
        $grid->disableActions();
        $grid->filter(function($filter){

            // 去掉默认的id过滤器
            $filter->disableIdFilter();
            // $filter->equal('currency_type','类型')->select(['balance' => '余额','btc'=>'比特币','electricity_fee'=>'电费']);
            $filter->equal('type','操作类型')->select(config('conf.user_log'));
            $filter->between('created_at', '时间')->datetime();

        });
        return $grid;
    }

}
